<cfparam name="Fund_ID" type="integer" default="0" />
<cfparam name="Organization_ID" type="integer" default="0" />
<cfparam name="returnView" type="string" default="funds" />
<cfparam name="passback" type="string" default="" />
<cfscript>
	fundGateway = new assets.calgrants.com.gateway.FundGateway();
	fund = fundGateway.get(Fund_ID = Fund_ID);
	if (fund.getFund_ID() eq 0 AND request.authUser.organizationID gt 0) {
		fund.setOrganization_ID(request.authUser.organizationID);
	} else if (Organization_ID gt 0) {
		fund.setOrganization_ID(Organization_ID);
	}
	if (fund.getFund_ID() eq 0) {
		fund.setRequested_By_ID(GetAuthUser());
		fund.setProgram_Year(request.currentProgramYear);
	}
</cfscript>
<cfif fund.getOrganization_ID() eq 0>
	<cfset returnView = "editFund" />
	<cfset cancelView = "funds" />
	<cfset passback = "Fund_ID,0" />
	<cfinclude template="/assets/calgrants/ui/forms/selectOrganization.cfm">
<cfelseif fund.getOrganization_ID() gt 0 and IsNumeric(fund.getFund_ID())>
	<cfscript>
		base = new assets.calgrants.com.Base();
		passbackQueryString = base.passbackToQueryString(passback);
		organizationGateway = new assets.calgrants.com.gateway.OrganizationGateway();
		organization = organizationGateway.get(Organization_ID = fund.getOrganization_ID());
		userGateway = new assets.calgrants.com.gateway.UserGateway();
		requestedBy = userGateway.get(User_ID = fund.getRequested_By_ID());
		approvedBy = userGateway.get(User_ID = fund.getApproved_By_ID());
		
		workshopGateway = new assets.calgrants.com.gateway.WorkshopGateway();
		workshops = workshopGateway.query(Organization_ID = fund.getOrganization_ID(), Approved = 1, Program_Year = request.currentProgramYear);
		
		fundWorkshopGateway = new assets.calgrants.com.gateway.FundWorkshopGateway();
		fundWorkshops = fundWorkshopGateway.query(Fund_ID = fund.getFund_ID());
		
		oapGateway = new assets.calgrants.com.gateway.OAPGateway();
		qOap = oapGateway.query(Organization_ID = fund.getOrganization_ID(), Program_Year = fund.getProgram_Year());
		oap = oapGateway.get(OAP_ID = qOAP.OAP_ID);
		oapValueGateway = new assets.calgrants.com.gateway.OAPValueGateway();
		oapValues = oapValueGateway.query(oapValueIDs = oap.getOAP_Value_IDs());
		if (fund.getProgram_Year() eq "2014-2015") {
			fundSurveyGateway = new assets.calgrants.com.gateway.FundSurvey2015Gateway();
		} else if (fund.getProgram_Year() eq "2013-2014") {
			fundSurveyGateway = new assets.calgrants.com.gateway.FundSurvey2014Gateway();
		} else if (fund.getProgram_Year() eq "2012-2013") {
			fundSurveyGateway = new assets.calgrants.com.gateway.FundSurvey2013Gateway();
		} else if (fund.getProgram_Year() eq "2011-2012") {
			fundSurveyGateway = new assets.calgrants.com.gateway.FundSurvey2012Gateway();
		} else if (fund.getProgram_Year() eq "2010-2011") {
			fundSurveyGateway = new assets.calgrants.com.gateway.FundSurvey2011Gateway();
		} else if (fund.getProgram_Year() eq "2009-2010") {
			fundSurveyGateway = new assets.calgrants.com.gateway.FundSurvey2010Gateway();
		}
		qFundSurvey = fundSurveyGateway.query(Fund_ID = fund.getFund_ID());
		fundSurvey = fundSurveyGateway.get(Fund_Survey_ID = IIf(fund.getFund_ID() gt 0, qFundSurvey.Fund_Survey_ID, 0));
		fundWorkshopAppealGateway = new assets.calgrants.com.gateway.FundWorkshopAppealGateway();
	</cfscript>
	<script type="text/javascript" language="javascript">
	<!--
		<cfoutput>
			var fundID = #fund.getFund_ID()#;
			var signature = "#Trim(requestedBy.getFirst_Name())# #Trim(requestedBy.getLast_Name())#";
			var userID = #request.authUser.userID#;
		</cfoutput>
		validate = function() {
			var errors = "";
			var valid = true;
			
			var payeeAddress = $("#Payee_Address").val();
			var pattern = new RegExp("\\b[p]*(ost)*\\.*\\s*[o|0]*(ffice)*\\.*\\s*b[o|0]x\\b", "i");
			if (payeeAddress.match(pattern)) {
				valid = false;
				errors += "Payments cannot be mailed a post office box.  Please enter a street address.\n";
			}
			if (fundID == 0 && userID !== 97561) {
				if ($("#Signature").val() !== signature) {
					valid = false;
					errors += "Signature must be the same as your name";	
				}
			}
			if (!valid) {
				alert(errors);
			} else {
				var checkTo = $("#Payee_Organization").val();
				var mailingAddy = $("#Payee_Organization").val() + "\n" + $("#Payee_Department").val() + "\nAttention: " + $("#Payee_First_Name").val() + " " + $("#Payee_Last_Name").val() + "\n" + $("#Payee_Address").val() + "\n" + $("#Payee_City").val() + ", CA " + $("#Payee_Zip_Code").val();
				if (!confirm("Please confirm the following information\n______________________________________\n\n" + "If sites qualify a check will be payable to:\n\n" + checkTo + "\n\n" + "If sites qualify a check will be shipped via UPS or FedEx to:\n\n" + mailingAddy)) {
					return false;
				};	
			}
			return valid;
		}
		/*
		openAppeal = function(fwaID) {
			$("#appealModal_" + fwaID).modal();
			$("#appealModal_" + fwaID + " .modal-body").css("max-height", 500);
			$("#appealModal_" + fwaID + " .modal-body").css("min-height", 500);
			$("#appealModal_" + fwaID + " .modal-body").css("height", 500);
		}
		closeAppeal = function(fwaID) {
			$("#appealModal_" + fwaID).modal("hide");	
		}
		saveAppeal = function(fwaID) {
			var args = {};
			args.objType = "fundWorkshopAppeal";
			args.Fund_Workshop_Appeal_ID = fwaID;
			args.Approved = $("#Approved_" + fwaID).val()
			args.Response = $("#Response_" + fwaID).val();
			console.log(args);
			$.ajax({
				url: "/assets/calgrants/com/API.cfc?method=update",
				data: args,
				dataType: "json",
				success: function(response) {
					if (args.Approved == true) {
						$("#appealButton_" + fwaID).removeClass("btn-danger").addClass("btn-success");
						$("#appealStatus_" + fwaID).text("Approved");
					} else {
						$("#appealButton_" + fwaID).removeClass("btn-danger").addClass("btn-warning");
						$("#appealStatus_" + fwaID).text("Rejected");
					}					
					closeAppeal(fwaID);
					return true;
				},
				error: function(response) {
					alert("There was an error saving the Fund Workshop Appeal");
					console.log(response);
					return false;
				}
			})
		}
		*/
		$(function() {
			$("#fundModal").modal();
			resizeModal("fundModal");
		})
	//-->
	</script>
	<style type="text/css">
		.slim-col {
			width: 70px;
		}
		.grid-table {
			width: 880px;
		}
		.q {
			padding-bottom: 10px;
		}
		.text-well {
			width: 820px;
		}
		.ta {
			width: 780px;
			height: 100px;
		}
	</style>
	<cfform id="fundForm" name="fundForm" action="#script_name#" method="post" onsubmit="return validate();">
		<cfinput type="hidden" name="action" value="saveFund" />
		<cfinput type="hidden" name="view" value="#returnView#" />
		<cfinput type="hidden" name="Fund_ID" value="#fund.getFund_ID()#" />
		<cfinput type="hidden" name="Organization_ID" value="#fund.getOrganization_ID()#" />
		<cfinput type="hidden" name="Requested_By_ID" value="#fund.getRequested_By_ID()#" />
		<cfinput type="hidden" name="Program_Year" value="#fund.getProgram_Year()#" />
		<cfoutput>
			<cfif IsDefined("passback")>
				<cfloop index="keyValue" list="#passback#" delimiters=";">
					<cfinput type="hidden" name="#ListFirst(keyValue)#" value="#ListLast(keyValue)#" />
				</cfloop>
			</cfif>
			<div id="fundModal" class="modal modal-fullscreen" data-backdrop="static">
				<div class="modal-header">
					<h3>Site Support Funds Request</h3>
				</div>
				<div class="modal-body">
					<div class="container-fluid">
						<!--- Payee Info --->
						<div class="row-fluid">
							<div class="span12">
								<h3>Payee Information</h3>
								<cfif fund.getFund_ID() eq 0>
									<p>Enter the exact organization name as it should appear on the check and the address where payment should be mailed.  Please include the phone and e-mail address of the payee.</p>
									<p>If any of the payee information is incorrect, payment may be delayed or lost. Also note, payment will only be made to organizations, <u>not individuals</u>.</p>
								</cfif>
							</div>
						</div>
						<div class="row-fluid">	
							<div class="span4">
								<cfif IsUserInRole("Super User")>
									<label class="required">Status</label>
									<div class="clearfix">
										<cfselect name="Approved" required="yes" message="Status is required" class="span9">
											<option value="0"<cfif fund.getApproved() eq 0> selected</cfif>>Not approved</option>
											<option value="1"<cfif fund.getApproved() eq 1> selected</cfif>>Approved</option>
										</cfselect>
									</div>
								<cfelse>
									<cfinput type="hidden" name="Approved" value="#fund.getApproved()#" />
									<cfif fund.getFund_ID() gt 0>
										<div class="text-control clearfix">
											<label class="required">Status</label>
											<cfif fund.getApproved() eq 1>
												Approved
											<cfelse>
												Pending approval
											</cfif>
										</div>
									<cfelse>
										<div class="text-control clearfix">
											<label class="required">Status</label>
											New
										</div>
									</cfif>
								</cfif>
								<div class="clearfix">
									<label class="required">First Name</label>
									<cfinput type="text" name="Payee_First_Name" value="#fund.getPayee_First_Name()#" required="yes" message="First Name is required" class="span12" />
								</div>
								<div class="clearfix">
									<label class="required">Last Name</label>
									<cfinput type="text" name="Payee_Last_Name" value="#fund.getPayee_Last_Name()#" required="yes" message="Last Name is required" class="span12" />
								</div>
								<div class="clearfix">
									<label class="required">Phone</label>
									<cfinput type="text" name="Payee_Phone" value="#fund.getPayee_Phone()#" required="yes" validate="telephone" placeholder="######-######-########" message="Phone is required and must be a valid telephone number" class="span12" />
								</div>
								<div class="clearfix">
									<label class="required">E-mail</label>
									<cfinput type="text" name="Payee_Email" value="#fund.getPayee_Email()#" required="yes" validate="email" message="E-mail is required and must be a valid e-mail address" class="span12" />
								</div>
								<cfif IsUserInRole("Super User") or IsUserInRole("Regional Admin")>
									<div class="clearfix">
										<label class="required">Tax ID</label>
										<cfinput type="text" name="Payee_Tax_ID" value="#fund.getPayee_Tax_ID()#" class="span12" />
									</div>
								</cfif>
							</div>
							<div class="span4">
								<div class="clearfix">
									<label class="required">Organization/School</label>
									<cfinput type="text" name="Payee_Organization" value="#fund.getPayee_Organization()#" required="yes" message="Organization/School is required" class="span12" />
								</div>
								<div class="clearfix">
									<label class="required">Office/Department</label>
									<cfinput type="text" name="Payee_Department" value="#fund.getPayee_Department()#" required="no" message="Office/Department is required" class="span12" />
								</div>
								<div class="clearfix">
									<label class="required">Address - No PO Boxes</label>
									<cfinput type="text" name="Payee_Address" value="#fund.getPayee_Address()#" required="yes" message="Address is required and cannot be a PO Box" class="span12" />
								</div>
								<div id="cityZipCodeContainer" class="clearfix">
									<div class="row-fluid">
										<div class="span8">
											<label for="Payee_City" class="required">City</label>
											<cfinput type="text" name="Payee_City" value="#fund.getPayee_City()#" required="yes" message="City is required" class="span12" />
										</div>
										<div class="span4">
											<label for="Payee_Zip_Code" class="required">Zip Code</label>
											<cfinput type="text" name="Payee_Zip_Code" value="#fund.getPayee_Zip_Code()#" required="yes" validate="zipcode" placeholder="##########" message="Zip Code is required and must be a valid zip code" class="span12" />
										</div>
									</div>
								</div>
							</div>
							<div class="span2">
								<div class="text-control clearfix">
									<label>Organization</label>
									#organization.getOrganization()#<br />
									#organization.getAddress()#<br />
									#organization.getCity()#, CA #organization.getZip_Code()#
								</div>
							</div>
							<div class="span2">
								<cfif fund.getFund_ID() gt 0>
									<div class="text-control clearfix">
										<label>Requested By</label>
										#requestedBy.getFirst_Name()# #requestedBy.getLast_Name()#<br />
										<a href="mailto:#requestedBy.getEmail()#">#requestedBy.getEmail()#</a><br />
										#requestedBy.getPhone()#<cfif Len(Trim(requestedBy.getExtension())) gt 0> x #requestedBy.getExtension()#</cfif>
									</div>
								</cfif>
								<cfif fund.getApproved_By_ID() gt 0>
									<div class="text-control clearfix">
										<label>Approved By</label>
										#approvedBy.getFirst_Name()# #approvedBy.getLast_Name()#
									</div>
									<div class="text-control clearfix">
										<label>Approval Date</label>
										#DateFormat(fund.getApproved_Date(), "m/d/yyyy")#
									</div>
								</cfif>
							</div>
						</div>
						<!--- Workshops --->
						<div class="row-fluid">
							<div class="span12">
								<h3>Workshops</h3>
								<cfif workshops.RecordCount gt 0>
									<cfif fund.getFund_ID() eq 0>
										<p>The workshops your organization conducted are listed below. Please enter attendance counts based on sign-in sheets.  If sign-in sheets are not available please estimate. The attendance counts may be different than exit survey counts. Also indicate the services that were offered at your workshop.</p>
									</cfif>
									<table class="table table-hover table-bordered">
										<thead>
											<tr>
												<th>Workshop</th>
												<th>Exit Surveys (Web/Paper)</th>
												<th>Funds Eligible</th>
												<th>Student Attendance</th>
												<th>Parent/Guardian Attendance</th>
												<th>Volunteer/Staff Attendance</th>
												<th>Computer Count</th>
												<th>Basic Services</th>
												<cfif IsUserInRole("Super User") or IsUserInRole("Regional Admin")>
													<th>Payment Amount</th>
												</cfif>
											</tr>
										</thead>
										<tbody>
											<cfif fund.getFund_ID() eq 0>
												<!--- output all workshops --->
												<cfloop query="workshops">
													<cfset pbStudentCount = IIf(Student_Count_PB eq 0 and PB_Survey_Count gt 0, PB_Survey_Count, Student_Count_PB) />
													<cfset studentCount = Student_Count_Web + pbStudentCount />
													<cfinput type="hidden" name="Fund_Workshop_ID" value="0" />
													<cfinput type="hidden" name="Workshop_ID" value="#Workshop_ID#" />
													<cfif studentCount gte 30 and Student_Count_Web gt 0>
														<cfset isEligible = true />
													<cfelse>
														<cfset isEligible = false />
													</cfif>
													<tr>
														<td>
															#Site#<br />
															#DateFormat(Workshop_Date, "m/d/yyyy")# #TimeFormat(Start_Time, "h:mmtt")#-#TimeFormat(End_Time, "h:mmtt")#
														</td>
														<td>#studentCount# (#Student_Count_Web#/#pbStudentCount#)</td>
														<td>
															#YesNoFormat(isEligible)#
															<cfif NOT isEligible>
																<div style="margin-top: 8px;">
																	<a href="##" id="fwaLink_#Workshop_ID#" onClick="openAppealModal(#Workshop_ID#); return false;" class="btn btn-success">Appeal</a>
																</div>
															</cfif>
														</td>
														<td><cfinput type="text" name="Student_Count_#Workshop_ID#" value="0" required="yes" validate="integer" message="Student Attendance is required and must be a number" style="width: 35px;"></td>
														<td><cfinput type="text" name="Parent_Count_#Workshop_ID#" value="0" required="yes" validate="integer" message="Parent Attendance is required and must be a number" style="width: 35px;"></td>
														<td><cfinput type="text" name="Volunteer_Count_#Workshop_ID#" value="0" required="yes" validate="integer" message="Volunteer Attendance is required and must be a number" style="width: 35px;"></td>
														<td><cfinput type="text" name="Computer_Count_#Workshop_ID#" value="0" required="yes" validate="integer" message="Computer Count is required and must be a number" style="width: 35px;"></td>
														<td>
															<label class="checkbox">
																<input type="checkbox" name="Online_#Workshop_ID#" value="true">
																Computer lab access to complete FAFSA/CA Dream Act Application
															</label>
															<label class="checkbox">
																<input type="checkbox" name="FAFSA_On_The_Web_#Workshop_ID#" value="true">
																FAFSA on the Web presentation
															</label>
															<label class="checkbox">
																<input type="checkbox" name="Financial_Aid_Presentation_#Workshop_ID#" value="true">
																Cal Grant &amp; other financial aid overview
															</label>
															<label class="checkbox">
																<input type="checkbox" name="Small_Group_#Workshop_ID#" value="true">
																One-on-one or small group assistance
															</label>
															<label class="checkbox">
																<input type="checkbox" name="AB540_#Workshop_ID#" value="true">
																AB540/CA Dream Act assistance
															</label>
														</td>
														<cfif IsUserInRole("Super User") or IsUserInRole("Regional Admin")>
															<td>
																<cfselect name="Fund_Amount_#Workshop_ID#" required="yes" message="Fund Amount is required" style="width: 80px;">	
																	<option value="0">0</option>
																	<option value="250">$250</option>
																</cfselect>
															</td>
														<cfelse>
															<cfinput type="hidden" name="Fund_Amount_#Workshop_ID#" value="0" />
														</cfif>
													</tr>
												</cfloop>
											<cfelse>
												<!--- output fund workshops --->
												<cfloop query="fundWorkshops">									
													<cfset pbStudentCount = IIf(Workshop_Student_Count_PB eq 0 and PB_Survey_Count gt 0, PB_Survey_Count, Workshop_Student_Count_PB) />
													<cfset studentCount = Workshop_Student_Count_Web + pbStudentCount />
													<cfinput type="hidden" name="Fund_Workshop_ID" value="#Fund_Workshop_ID#" />
													<cfinput type="hidden" name="Workshop_ID" value="#Workshop_ID#" />
													<cfif studentCount gte 30 and Workshop_Student_Count_Web gt 0>
														<cfset isEligible = true />
													<cfelse>
														<cfset isEligible = false />
													</cfif>
													<tr>
														<td>
															#Site#<br />
															#DateFormat(Workshop_Date, "m/d/yyyy")# #TimeFormat(Start_Time, "h:mmtt")#-#TimeFormat(End_Time, "h:mmtt")#
														</td>
														<td>#studentCount# (#Workshop_Student_Count_Web#/#pbStudentCount#)</td>
														<td>
															#YesNoFormat(isEligible)#
															<cfif NOT isEligible>
																<cfscript>
																	fundWorkshopAppeals = fundWorkshopAppealGateway.query(Workshop_ID = Workshop_ID);
																</cfscript>
																<div style="margin-top: 8px;">
																	<cfif fundWorkshopAppeals.RecordCount gt 0>
																		<cfif Len(Trim(fundWorkshopAppeals.Response)) gt 0 and fundWorkshopAppeals.Approved eq 0>
																			<a href="##" id="fwaLink_#Workshop_ID#" onClick="openAppealModal(#Workshop_ID#); return false;">Appeal - Rejected</a>
																		<cfelseif Len(Trim(fundWorkshopAppeals.Response)) gt 0 and fundWorkshopAppeals.Approved eq 1>
																			<a href="##" id="fwaLink_#Workshop_ID#" onClick="openAppealModal(#Workshop_ID#); return false;">Appeal - Approved</a>
																		<cfelseif fundWorkshopAppeals.Approved eq 0>
																			<a href="##" id="fwaLink_#Workshop_ID#" onClick="openAppealModal(#Workshop_ID#); return false;">Appeal - Pending</a>
																		</cfif>
																	<cfelse>
																		<a href="##" id="fwaLink_#Workshop_ID#" onClick="openAppealModal(#Workshop_ID#); return false;" class="btn btn-success">Appeal</a>
																	</cfif>
																</div>
															</cfif>
														</td>
														<td><cfinput type="text" name="Student_Count_#Workshop_ID#" value="#Student_Count#" required="yes" validate="integer" message="Student Attendance is required and must be a number" style="width: 35px;"></td>
														<td><cfinput type="text" name="Parent_Count_#Workshop_ID#" value="#Parent_Count#" required="yes" validate="integer" message="Parent Attendance is required and must be a number" style="width: 35px;"></td>
														<td><cfinput type="text" name="Volunteer_Count_#Workshop_ID#" value="#Volunteer_Count#" required="yes" validate="integer" message="Volunteer Attendance is required and must be a number" style="width: 35px;"></td>
														<td><cfinput type="text" name="Computer_Count_#Workshop_ID#" value="#Computer_Count#" required="yes" validate="integer" message="Computer Count is required and must be a number" style="width: 35px;"></td>
														<td>
															<label class="checkbox">
																<input type="checkbox" name="Online_#Workshop_ID#" value="true"<cfif Online> checked</cfif>>
																Computer lab access to complete FAFSA/CA Dream Act Application
															</label>
															<label class="checkbox">
																<input type="checkbox" name="FAFSA_On_The_Web_#Workshop_ID#" value="true"<cfif FAFSA_On_The_Web> checked</cfif>>
																FAFSA on the Web presentation
															</label>
															<label class="checkbox">
																<input type="checkbox" name="Financial_Aid_Presentation_#Workshop_ID#" value="true"<cfif Financial_Aid_Presentation> checked</cfif>>
																Cal Grant &amp; other financial aid overview
															</label>
															<label class="checkbox">
																<input type="checkbox" name="Small_Group_#Workshop_ID#" value="true"<cfif Small_Group> checked</cfif>>
																One-on-one or small group assistance
															</label>
															<label class="checkbox">
																<input type="checkbox" name="AB540_#Workshop_ID#" value="true"<cfif AB540> checked</cfif>>
																AB540/CA Dream Act assistance
															</label>
														</td>
														<cfif IsUserInRole("Super User") or IsUserInRole("Regional Admin")>
															<td>
																<cfselect name="Fund_Amount_#Workshop_ID#" required="yes" message="Fund Amount is required" style="width: 80px;">	
																	<option value="0">0</option>
																	<option value="300"<cfif Fund_Amount eq 300> selected</cfif>>$300</option>
																</cfselect>
															</td>
														<cfelse>
															<cfinput type="hidden" name="Fund_Amount_#Workshop_ID#" value="#Fund_Amount#" />
															<!--- #DollarFormat(Fund_Amount)# --->
														</cfif>
													</tr>
												</cfloop>
											</cfif>									
										</tbody>
									</table>
								<cfelse>
									<div class="alert alert-info notFound">No workshops</div>
								</cfif>
							</div>
						</div>
						<!--- OAP --->
						<div class="row-fluid">
							<div class="span12">
								<h3>Outreach Actvities</h3>
								<cfif fund.getFund_ID() eq 0 or NOT fund.getApproved()>
									<p>Below are the outreach activities you listed in your Outreach Action Plan. Please confirm which outreach activities were conducted by checking off the box to the left of the activity, and list any new activities not previously listed in your Outreach Action Plan.</p>
									<cfinclude template="/assets/calgrants/ui/forms/fundOAP.cfm">
								<cfelse>
									<cfinclude template="/assets/calgrants/ui/details/fundOAP.cfm">
								</cfif>
							</div>
						</div>
						<!--- Survey --->
						<div class="row-fluid">
							<div class="span12">
								<h3>Organizer Survey</h3>
								<cfinput type="hidden" name="Fund_Survey_ID" value="#fundSurvey.getFund_Survey_ID()#" />
								<!--- <cfif fund.getFund_ID() eq 0 OR NOT fund.getApproved()> --->
									<cfinclude template="/assets/calgrants/ui/forms/fundSurvey#ListLast(fund.getProgram_Year(), '-')#.cfm">
								<!--- <cfelse>
									<cfinclude template="/assets/calgrants/ui/details/fundSurvey#ListLast(fund.getProgram_Year(), '-')#.cfm">
								</cfif> --->				
							</div>
						</div>
						<!--- Signature --->
						<cfif fund.getFund_ID() eq 0>
							<div class="row-fluid">
								<div class="span12">
									<h3>Signature</h3>
									<div class="clearfix">
										<cfinput type="text" name="Signature" value="#fund.getSignature()#" required="yes" message="Signature is required and must be the same as your name" class="span3" /><br />
										#requestedBy.getFirst_Name()# #requestedBy.getLast_Name()#
									</div>
								</div>
							</div>
						</cfif>
					</div>
				</div>
				<div class="modal-footer">
					<cfif fund.getFund_ID() eq 0>
						<a href="?view=#returnView#&#passbackQueryString#" class="btn btn-success">Cancel</a>
						<button type="submit" name="saveButton" class="btn btn-success">Submit</button>
					<cfelseif IsUserInRole("Super User") OR IsUserInRole("Regional Admin")>
						<a href="?view=#returnView#&#passbackQueryString#" class="btn btn-success">Cancel</a>
						<button type="submit" name="saveButton" class="btn btn-success">Save</button>
					<cfelse>
						<a href="?view=#returnView#&#passbackQueryString#" class="btn btn-success">Close</a>
					</cfif>
					<cfif (IsUserInRole("Super User") OR IsUserInRole("Regional Admin")) AND fund.getFund_ID() gt 0>
						<cfinput type="submit" name="invoiceButton" class="btn btn-success" value="Save + Generate Invoice" />
					</cfif>
				</div>
			</div>
		</cfoutput>
	</cfform>
	<!--- Appeal modals --->
	<cfoutput>
		<cfif fund.getFund_ID() eq 0>
			<cfloop query="workshops">
				<cfset pbStudentCount = IIf(Student_Count_PB eq 0 and PB_Survey_Count gt 0, PB_Survey_Count, Student_Count_PB) />
				<cfset studentCount = Student_Count_Web + pbStudentCount />
				<cfif studentCount gte 30 and Student_Count_Web gt 0>
					<cfset isEligible = true />
				<cfelse>
					<cfset isEligible = false />
				</cfif>
				<cfif NOT isEligible>
					<script type="text/javascript">
						var openAppealModal = function(wID) {
							$("##fwaModal_" + wID).modal("show");
						}
						var submitAppeal = function(wID) {
							$.ajax({
								type: "post",
								url: "/assets/calgrants/com/API.cfc?method=create",
								data: $("##fwaForm_" + wID).serialize(),
								async: true,
								cache: false,
								dataType: "json",
								success: function(response, textStatus, jqXHR){
									$("##fwaLink_" + wID).text("Appealed");
									$("##fwaLink_" + wID).removeClass("btn");
									$("##fwaLink_" + wID).removeClass("btn-success");
									$("##Fund_Workshop_Appeal_ID_" + wID).val(response.DATA.Fund_Workshop_Appeal_ID);
									$("##fwaModal_" + wID).modal("hide");
								},
								error: function(jqXHR, textStatus, errorThrown){
									alert("Error submitting appeal");
									$("##fwaModal_" + wID).modal("hide");
								}
							});
						}
						$(function() {
							$(".appeal-modal").modal({
								backdrop: "static",
								keyboard: false,
								show: false
							});
						})
					</script>
					<cfform id="fwaForm_#Workshop_ID#" name="fwaForm_#Workshop_ID#" onsubmit="submitAppeal(#Workshop_ID#); return false;">
						<cfinput type="hidden" id="objType_#Workshop_ID#" name="objType" value="fundWorkshopAppeal" />
						<cfinput type="hidden" id="Fund_Workshop_Appeal_ID_#Workshop_ID#" name="Fund_Workshop_Appeal_ID" value="0" />
						<cfinput type="hidden" id="Organization_ID_#Workshop_ID#" name="Organization_ID" value="#Organization_ID#" />
						<cfinput type="hidden" id="Workshop_ID_#Workshop_ID#" name="Workshop_ID" value="#Workshop_ID#" />
						<cfinput type="hidden" id="Approved_#Workshop_ID#" name="Approved" value="0" />
						<cfinput type="hidden" id="Appealed_By_ID_#Workshop_ID#" name="Appealed_By_ID" value="#request.authUser.userID#" />
						<div id="fwaModal_#Workshop_ID#" tabindex="-1" role="dialog" class="modal appeal-modal hide" style="width: 700px;">
							<div class="modal-header">
								<h3>Site Support Funds Workshop Appeal</h3>
							</div>
							<div class="modal-body">
								<div class="row-fluid">
									<div class="span8">
										<h4 id="appealWorkshopLabel">
											#Site#<br />
											#DateFormat(Workshop_Date, "m/d/yyyy")# #TimeFormat(Start_Time, "h:mmtt")#-#TimeFormat(End_Time, "h:mmtt")#
										</h4>
									</div>
									<div class="span4">
										<table class="table table-bordered fwaSurveysCountTable" style="margin-bottom: 6px;">
											<tr>
												<th>Web Exit Suveys</th>
												<td class="right">#Student_Count_Web#</td>
											</tr>
											<tr>
												<th>Paper Exit Surveys</th>
												<td class="right">#pbStudentCount#</td>
											</tr>
											<tr>
												<th>Total Exit Surveys</th>
												<td class="right">#studentCount#</td>
											</tr>
										</table>
									</div>
								</div>
								<div class="clearfix">
									<label class="required">Appeal</label>
									<p>Explain the circumstances which prohibited you from offering computers at the workshop or using the online exit survey tool.</p>
									<cftextarea id="Appeal_#Workshop_ID#" name="Appeal" required="yes" message="Appeal is required" style="width: 650px; height: 150px;"></cftextarea>
								</div>
							</div>
							<div class="modal-footer">
								<button  class="btn btn-success" data-dismiss="modal" aria-hidden="true">Cancel</button>
								<button type="submit" name="saveButton" class="btn btn-success">Submit</button>
							</div>
						</div>
					</cfform>
				</cfif>
			</cfloop>
		<cfelse>
			<cfloop query="fundWorkshops">
				<cfset pbStudentCount = IIf(Workshop_Student_Count_PB eq 0 and PB_Survey_Count gt 0, PB_Survey_Count, Workshop_Student_Count_PB) />
				<cfset studentCount = Workshop_Student_Count_Web + pbStudentCount />
				<cfif studentCount gte 30 and Workshop_Student_Count_Web gt 0>
					<cfset isEligible = true />
				<cfelse>
					<cfset isEligible = false />
				</cfif>
				<cfif NOT isEligible>
					<script type="text/javascript">
						var openAppealModal = function(wID) {
							$("##fwaModal_" + wID).modal("show");
						}
						var submitAppeal = function(wID) {
							$.ajax({
								type: "post",
								url: "/assets/calgrants/com/API.cfc?method=save",
								data: $("##fwaForm_" + wID).serialize(),
								async: true,
								cache: false,
								dataType: "json",
								success: function(response, textStatus, jqXHR){
									fwaId = $("##Fund_Workshop_Appeal_ID_" + wID).val();
									$("##fwaLink_" + wID).removeClass("btn");
									$("##fwaLink_" + wID).removeClass("btn-success");
									if (fwaId === 0) {
										$("##fwaLink_" + wID).text("Appealed");
										$("##Fund_Workshop_Appeal_ID_" + wID).val(response.DATA.Fund_Workshop_Appeal_ID);
									} else {
										if (response.DATA.Response.length > 0) {
											//alert(response.DATA.Approved);
											if (parseInt(response.DATA.Approved) === 1) {
												$("##fwaLink_" + wID).text("Appeal - Approved");
											} else {
												$("##fwaLink_" + wID).text("Appeal - Rejected");
											}
										} else {
											$("##fwaLink_" + wID).text("Appeal - Pending");
										}
									}
									$("##fwaModal_" + wID).modal("hide");
								},
								error: function(jqXHR, textStatus, errorThrown){
									alert("Error submitting appeal");
									$("##fwaModal_" + wID).modal("hide");
								}
							});
						}
						$(function() {
							$(".appeal-modal").modal({
								backdrop: "static",
								keyboard: false,
								show: false
							});
						})
					</script>
					<cfform id="fwaForm_#Workshop_ID#" name="fwaForm_#Workshop_ID#" onsubmit="submitAppeal(#Workshop_ID#); return false;">						
						<cfinput type="hidden" id="objType_#Workshop_ID#" name="objType" value="fundWorkshopAppeal" />
						<cfinput type="hidden" id="Fund_Workshop_Appeal_ID_#Workshop_ID#" name="Fund_Workshop_Appeal_ID" value="#Fund_Workshop_Appeal_ID#" />
						<cfinput type="hidden" id="Organization_ID_#Workshop_ID#" name="Organization_ID" value="#Organization_ID#" />
						<cfinput type="hidden" id="Workshop_ID_#Workshop_ID#" name="Workshop_ID" value="#Workshop_ID#" />
						<cfinput type="hidden" id="Appealed_By_ID_#Workshop_ID#" name="Appealed_By_ID" value="#Appealed_By_ID#" />
						<div id="fwaModal_#Workshop_ID#" tabindex="-1" role="dialog" class="modal appeal-modal hide" style="width: 700px;">
							<div class="modal-header">
								<h3>Site Support Funds Workshop Appeal</h3>
							</div>
							<div class="modal-body">
								<div class="row-fluid">
									<div class="span8">
										<h4 id="appealWorkshopLabel">
											#Site#<br />
											#DateFormat(Workshop_Date, "m/d/yyyy")# #TimeFormat(Start_Time, "h:mmtt")#-#TimeFormat(End_Time, "h:mmtt")#
										</h4>
									</div>
									<div class="span4">
										<table class="table table-bordered fwaSurveysCountTable" style="margin-bottom: 6px;">
											<tr>
												<th>Web Exit Suveys</th>
												<td class="right">#Workshop_Student_Count_PB#</td>
											</tr>
											<tr>
												<th>Paper Exit Surveys</th>
												<td class="right">#pbStudentCount#</td>
											</tr>
											<tr>
												<th>Total Exit Surveys</th>
												<td class="right">#studentCount#</td>
											</tr>
										</table>
									</div>
								</div>
								<div class="text-control">
									<label>Status</label>
									<cfif IsUserInRole("Super User")>
										<cfselect id="Approved_#Workshop_ID#" name="Approved" required="yes" message="Status is required" class="span9">
											<option value="0"<cfif Fund_Workshop_Appeal_Approved eq 0> selected</cfif>>Not approved</option>
											<option value="1"<cfif Fund_Workshop_Appeal_Approved eq 1> selected</cfif>>Approved</option>
										</cfselect>
									<cfelse>
										<cfinput type="hidden" id="Approved_#Workshop_ID#" name="Approved" value="#Fund_Workshop_Appeal_Approved#" />
										<cfif Len(Trim(Response)) gt 0 and Fund_Workshop_Appeal_Approved eq 0>
											Rejected
										<cfelseif Len(Trim(Response)) gt 0 and Fund_Workshop_Appeal_Approved eq 1>
											Approved
										<cfelse>
											Pending
										</cfif>
									</cfif>
								</div>
								<div class="clearfix">
									<cfif IsUserInRole("Super User")>
										<label class="required">Appeal</label>
									<cfelse>
										<label class="required">Explain the circumstances which prohibited you from offering computers at the workshop or using the online exit survey tool.</label>
									</cfif>
									<cftextarea name="Appeal_#Workshop_ID#" required="yes" message="Appeal is required" style="width: 650px; height: 150px;">#Appeal#</cftextarea>
								</div>
								<div class="clearfix">
									<label class="required">Response</label>
									<cfif IsUserInRole("Super User")>
										<cftextarea id="Response_#Workshop_ID#" name="Response" required="yes" message="Response is required" style="width: 650px; height: 150px;">#Response#</cftextarea>
									<cfelse>
										<cfinput type="hidden" id="Response_#Workshop_ID#" name="Response" value="#Response#" />
										<div class="well well-framed">
											#Response#
										</div>
									</cfif>
								</div>
							</div>
							<div class="modal-footer">
								<cfif IsUserInRole("Super User")>
									<button  class="btn btn-success" data-dismiss="modal" aria-hidden="true">Cancel</button>
									<button type="submit" name="saveButton" class="btn btn-success">Save</button>
								<cfelse>
									<cfif Len(Trim(Response)) eq 0>
										<button  class="btn btn-success" data-dismiss="modal" aria-hidden="true">Cancel</button>
										<button type="submit" name="saveButton" class="btn btn-success">Save</button>
									<cfelse>
										<button  class="btn btn-success" data-dismiss="modal" aria-hidden="true">Close</button>
									</cfif>
								</cfif>
							</div>
						</div>
					</cfform>
				</cfif>
			</cfloop>
		</cfif>
	</cfoutput>
<cfelse>
	<div class="alert alert-info notFound">Site Support Funds Request not found</div>
</cfif>